# -*- coding: utf-8 -*-
from .base import *

DEBUG = False
# 允许的ip
ALLOWED_HOSTS = ['*']

# 配置数据库
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',  # 指明用的是mysql数据库
        'HOST': 'xxxxxx',  # 数据库主机
        'PORT': 3306,  # 数据库端口
        'USER': 'xxxxxx',  # 数据库用户名
        'PASSWORD': 'xxxxxx',  # 数据库用户密码
        'NAME': 'xxxxxx',  # 数据库名字,
        'TEST': {  # 测试数据库配置
            "NAME": "xxxxxx"  # 跑测试用例需要用到，切记该名字不能与开发数据库一样
        }
    }
}

# redis配置
MASTER_NAME = 'xxxxxx'
LOCATION = f'{MASTER_NAME}/xxxxxx:26379/0'
REDIS_PASSWORD = "1qaz@WSX"
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": LOCATION,
        "OPTIONS": {
            "PASSWORD": REDIS_PASSWORD,
            "CLIENT_CLASS": "django_sentinel.SentinelClient",
            "connection_pool_kwargs": {"max_connections": 100}
        }
    }
}

'''
redis-cli -h xxx-p 26379 info sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
sentinel_simulate_failure_flags:0
master0:name=jcptmaster,status=ok,address=xxx:6379,slaves=1,sentinels=1
'''

# Celery配置 Broker的地址
BROKER_BACKEND = 'redis'
CELERY_BROKER_URL = f"sentinel://:{REDIS_PASSWORD}@xxxxxx:26379/1;"
CELERY_BROKER_TRANSPORT_OPTIONS = {"master_name": MASTER_NAME}
CELERY_RESULT_BACKEND_TRANSPORT_OPTIONS = {"master_name": MASTER_NAME}